package com.example.design.patterns.冰河.结构型模式.组合模式;

import com.example.design.patterns.冰河.结构型模式.组合模式.component.Employer;
import com.example.design.patterns.冰河.结构型模式.组合模式.composie.ProjectManager;
import com.example.design.patterns.冰河.结构型模式.组合模式.leaf.Programmer;
import com.example.design.patterns.冰河.结构型模式.组合模式.leaf.ProjectAssistant;
import java.util.List;

/**
 * Client通过Component接口操纵组合部件的对象
 */
public class Test {
    public static void main(String[] args) {
        ProjectManager pm = new ProjectManager("项目经理");
        ProjectAssistant pa = new ProjectAssistant("项目助理");
        Programmer programmer1 = new Programmer("程序员一");
        Programmer programmer2 = new Programmer("程序员二");

        pm.add(pa);//为项目经理添加项目助理
        pm.add(programmer2);//为项目经理添加程序员

        List<Employer> employers = pm.getEmployers();
        for (Employer employer : employers) {
            System.out.println(employer.getName());
        }
    }
}
